package cn.redragon.soa.security;

import cn.redragon.soa.common.core.constant.AuthConstant;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import org.springframework.security.web.util.matcher.RequestMatcher;

public class JwtBearerRequestMatcher implements RequestMatcher {

    @Override
    public boolean matches(final HttpServletRequest request) {
        String headerValue = request.getHeader(AuthConstant.AUTH_HEADER);
        if (null == headerValue) {
            return false;
        }

        return StringUtils.startsWithIgnoreCase(headerValue, AuthConstant.BEARER_AUTH_PREFIX);

    }
}
